using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace GuavaLib
{
    public partial class GRoot : Form, GuavaForm
    {
        string gname;
        string gtype;
        protected DataSet thisds;

        public GRoot()
        {
            InitializeComponent();
        }

        #region GuavaForm Members

        public Guid ID
        {
            get
            {
                return new Guid();
            }
            set
            {
                return;
            }
        }

        public void AttachData(DataSet ds, Guid id, int i)
        {
            foreach (Guava cc in GComponents)
            {
                cc.GBind(ds, this.GText, i);
            }
        }

        public void Save()
        {
            this.thisds.Tables[this.GName].AcceptChanges();
            this.Close();
        }

        public void Cancel()
        {
            this.thisds.Tables[this.GName].RejectChanges();
            this.Close();
        }

        #endregion

        #region Guava Members

        public LaunchType LType
        {
            get
            {
                return GuavaLib.LaunchType.NA;
            }
        }

        public ControlType CType
        {
            get
            {
                return GuavaLib.ControlType.Entity;
            }
        }

        public string GType
        {
            get
            {
                return this.gtype;
            }
            set
            {
                this.gtype = value;
            }
        }

        public string GText
        {
            get
            {
                return this.Text;
            }
        }

        public string GName
        {
            get
            {
                if (gname == null) return this.Name;
                return gname;
            }
            set
            {
                gname = value;
            }
        }

        public Point GLocation
        {
            get { return this.Location; }
        }

        public Size GSize
        {
            get { return this.Size; }
        }

        public List<Guava> GComponents
        {
            get
            {
                List<Guava> lg = new List<Guava>();

                foreach (Control c in this.Controls)
                {
                    if (c is Guava) lg.Add((Guava)c);
                }

                return lg;
            }
        }

        public void GBind(DataSet ds, string table, int i)
        {
            return;
        }

        public Type NaiveDataType
        {
            get { return null; }
        }

        #endregion

        protected void Init()
        {


            return;
        }
    }
}